﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_UPDMS_COM_PGM_GRID_COLUMN_Get_Column_List_By_Pgm_Id_N_Grid_Id')
	BEGIN
		DROP Procedure usp_UPDMS_COM_PGM_GRID_COLUMN_Get_Column_List_By_Pgm_Id_N_Grid_Id
	END
GO

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
/******************************************************************************
**	Name : usp_UPDMS_COM_PGM_GRID_COLUMN_Get_Column_List_By_Pgm_Id_N_Grid_Id
**	Desc : 프로그램별 그리드별 컬럼정보 조회
**	Test Exec Query : Exec usp_UPDMS_COM_PGM_GRID_COLUMN_Get_Column_List_By_Pgm_Id_N_Grid_Id 'Crd1012m', 'GridView1', 'ko'
**	Called by : All
**	Program ID : All
**	Auth : 송시명
**	Date : 2011-02-15
*******************************************************************************
**	Change History
*******************************************************************************
**	Date:		Author:		Description:
**	--------	--------	---------------------------------------
**	
*******************************************************************************/
CREATE PROC [dbo].[usp_UPDMS_COM_PGM_GRID_COLUMN_Get_Column_List_By_Pgm_Id_N_Grid_Id]
@ls_pgm_id nvarchar(20),
@ls_grid_id nvarchar(50),
@ls_lang_set nvarchar(2)
AS
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SET NOCOUNT ON

SELECT a.Grid_Id,
       a.Col_Idx,
       CONVERT(NVARCHAR, a.Col_Idx) + '|' + CONVERT(NVARCHAR,ISNULL(b.Seq, '')) + '|' + ISNULL(a.Col_Nm,'') AS Label_Id,
       CASE WHEN b.Label_Ko IS NULL THEN ''
            ELSE ISNULL(b.Label_Ko, '') + ' (' + ISNULL(b.Label_En,'') + ')' + '(' + ISNULL(a.Col_Nm,'') + ')'
       END Label_Nm
  FROM UPDMS_COM_PGM_GRID_COLUMN AS a WITH(NOLOCK)
  LEFT OUTER JOIN UPDMS_COM_LABEL AS b WITH(NOLOCK) ON a.Label_Id = b.Seq
 WHERE a.Pgm_Id = @ls_pgm_id
   AND a.Grid_Id = @ls_grid_id
 ORDER BY a.Grid_Id, a.Col_Idx

GO